#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>

#include "list_of_commands.hpp"
#include "list_of_operators.hpp"
#include "variable.hpp"
#include "token.hpp"
#include "utility_functions.hpp"
#include "load_program.hpp"
#include "execute_instructions.hpp"

void print_tokens(std::vector<token> program)
{
    for(unsigned i = 0; i < program.size(); i++)
    {
        if(program[i].is_line_number()) std::cout << "line number" << "\t" << ":";
        if(program[i].is_comma()) std::cout << "comma     " << "\t" << ":";
        if(program[i].is_constant()) std::cout << "constant" << "\t" << ":";
        if(program[i].is_literal()) std::cout << "literal   " << "\t" << ":";
        if(program[i].is_end_of_file()) std::cout << "end of file" << "\t" << ":";
        if(program[i].is_end_of_line()) std::cout << "end of line" << "\t" << ":";
        if(program[i].is_semicolon()) std::cout << "semicolon " << "\t" << ":";
        if(program[i].is_operator()) std::cout << "operator" << "\t" << ":";
        if(program[i].is_identifier()) std::cout << "identifier" << "\t" << ":";
        if(program[i].is_command()) std::cout << "command  " << "\t" << ":";
        std::cout << program[i].get_string() << "\n";
    }
    std::cout << std::flush;
    return;
}


int main(int argc, char **argv)
{
    std::vector<token> program;

    init_list_of_commands();
    init_list_of_operators();
    if(argc != 2)
    {
        usage();
    }

    program  = load_program(argv[1]);
    print_tokens(program);
    execute_instructions(program);
    system("pause");

    return 0;
}
